<template>
  <div>
    <!-- 面包屑 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>分类管理</el-breadcrumb-item>
      <el-breadcrumb-item>文件分类导出</el-breadcrumb-item>
    </el-breadcrumb>

    <el-card shadow="always" :body-style="{ padding: '20px' }">
      <div>
        <el-select v-model="value" placeholder="请选择" @change="exportChange">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
          <el-button type="primary" @click='exportA'>
            <!-- <a :href="`http://localhost:3000/admin/api/export/downloadClassification?classification=${this.value}`">导出</a> -->
            导出
          </el-button>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      options: [
        {
          value: "0",
          label: "教材",
        },
        {
          value: "1",
          label: "线上培训",
        },
        {
          value: "2",
          label: "线下培训",
        },
        {
          value: "3",
          label: "校企技术服务",
        },
        {
          value: "4",
          label: "精品课程",
        },
        {
          value: "5",
          label: "指导学生比赛获奖",
        },
      ],
      value: "0",
    };
  },
  methods: {
    exportChange(val) {
      this.value = val
    },
    exportA() {
      this.$confirm(`确认要导出文件吗, 是否继续?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$message({
            type: 'success',
            message: '导出成功!'
          });
          window.open(`http://localhost:3000/admin/api/export/downloadClassification?classification=${this.value}`,'_sef')
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消导出'
          });          
        });
    }
  },
};
</script>

<style lang="less" scoped>
.el-select {
  width: 350px;
}
.el-button{
  margin: 0 15px;
  a{
    color: #fff;
    text-decoration: none;
  }
}
</style>